package com.samapp.map;

import java.util.List;

import com.samapp.R;
import com.samapp.entity.ClientOrder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ClientIndentAdapter extends BaseAdapter {
	private LayoutInflater mInflater;
	private List<ClientOrder> mIndents;
	private Context context;
	
	public ClientIndentAdapter(Context context, List<ClientOrder> mIndents) {
		this.context = context;
		this.mInflater = LayoutInflater.from(context);
		this.mIndents = mIndents;
	}
	
	@Override
	public int getCount() {
		return mIndents.size();
	}

	@Override
	public Object getItem(int position) {
		return mIndents.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.client_indent_item, parent, false);
			holder = new ViewHolder();
			holder.createTime = (TextView) convertView.findViewById(R.id.textview_createTime);
			holder.user = (TextView) convertView.findViewById(R.id.textview_user);
			holder.price = (TextView) convertView.findViewById(R.id.textview_price);
			holder.orderDetail = (TextView) convertView.findViewById(R.id.textview_orderDetail);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		ClientOrder mIndent = mIndents.get(position);
		holder.createTime.setText(mIndent.getCreateTime());
		holder.user.setText(mIndent.getUser());
		holder.price.setText(""+mIndent.getPrice());
		holder.orderDetail.setText(mIndent.getOrderDetail());
		return convertView;
	}

	private class ViewHolder {
		TextView createTime;
		TextView user;
		TextView price;
		TextView orderDetail;
	}

}
